function pos = blkpos(x,findBlkName)
% blkpos  [Not a public function] Positions of blocks in theparser struct.
%
% Backend IRIS function.
% No help provided.

% -IRIS Toolbox.
% -Copyright (c) 2007-2015 IRIS Solutions Team.

%--------------------------------------------------------------------------

if ischar(findBlkName)
    findBlkName = {findBlkName};
end

nFind = numel(findBlkName);
pos = nan(size(findBlkName));
listBlkName = { x(:).BlkName };
for iFind = 1 : nFind
    ix = strcmp(listBlkName, findBlkName{iFind});
    if any(ix)
        pos(iFind) = find(ix,1);
    end
end

if any(isnan(pos))
    utils.error('theparser:blkpos', ...
        'Block not found in the parser object: ''%s''.', ...
        findBlkName{isnan(pos)});
end

end
